package com.chen.blue.converter.business;

import com.chen.blue.domain.dto.business.ContestApplyRecordDto;
import com.chen.blue.domain.dto.business.update.ContestApplyRecordDtoEdit;
import com.chen.blue.domain.model.business.ContestApplyRecordModel;
import com.chen.blue.domain.vo.business.ContestApplyRecordVo;
import org.springframework.cglib.beans.BeanCopier;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Created By CLT On 2024/5/24.
 */
@SuppressWarnings("all")
public abstract class ContestApplyRecordConverter {

    private static final BeanCopier modelToVo = BeanCopier.create(ContestApplyRecordModel.class, ContestApplyRecordVo.class, false);
    private static final BeanCopier dtoToModel = BeanCopier.create(ContestApplyRecordDto.class, ContestApplyRecordModel.class, false);
    private static final BeanCopier dtoEditToModel = BeanCopier.create(ContestApplyRecordDtoEdit.class, ContestApplyRecordModel.class, false);

    /**
     * model->vo
     *
     * @param model
     * @return
     */
    public static ContestApplyRecordVo modelToVo(ContestApplyRecordModel model) {
        if (Objects.isNull(model)) {
            return null;
        }
        ContestApplyRecordVo contestApplyRecordVo = new ContestApplyRecordVo();
        modelToVo.copy(model, contestApplyRecordVo, null);
        return contestApplyRecordVo;
    }

    /**
     * model->volist
     *
     * @param modelList
     * @return
     */
    public static List<ContestApplyRecordVo> modelToVoList(List<ContestApplyRecordModel> modelList) {
        if (modelList.size() == 0) {
            return null;
        }

        List<ContestApplyRecordVo> contestApplyRecordVoList = new ArrayList<>();
        for (ContestApplyRecordModel contestApplyRecordModel : modelList) {
            contestApplyRecordVoList.add(modelToVo(contestApplyRecordModel));
        }

        return contestApplyRecordVoList;

    }

    /**
     * dto->model
     *
     * @param contestApplyRecordDto
     * @return
     */
    public static ContestApplyRecordModel dtoToModel(ContestApplyRecordDto contestApplyRecordDto) {

        if (Objects.isNull(contestApplyRecordDto)) {
            return null;
        }

        ContestApplyRecordModel contestApplyRecordModel = new ContestApplyRecordModel();
        dtoToModel.copy(contestApplyRecordDto, contestApplyRecordModel, null);
        return contestApplyRecordModel;

    }

    /**
     * editDto->model
     *
     * @param contestApplyRecordDtoEdit
     * @return
     */
    public static ContestApplyRecordModel dtoEditToModel(ContestApplyRecordDtoEdit contestApplyRecordDtoEdit) {

        if (Objects.isNull(contestApplyRecordDtoEdit)) {
            return null;
        }

        ContestApplyRecordModel contestApplyRecordModel = new ContestApplyRecordModel();
        dtoEditToModel.copy(contestApplyRecordDtoEdit, contestApplyRecordModel, null);
        return contestApplyRecordModel;

    }

}
